package org.bagou.xiangs.framework_mvp

import org.junit.Assert.assertEquals
import org.junit.Test
import java.util.*

/**
 * Example local unit test, which will execute on the development machine (host).
 *
 * See [testing documentation](http://d.android.com/tools/testing).
 */
class ExampleUnitTest {
    @Test
    fun addition_isCorrect() {
        assertEquals(4, 2 + 2)
    }

    @Test
    fun showException() {
        val list: ArrayList<String> = ArrayList<String>()
        list.add("我")
        list.add("爱")
        list.add("你");
        list.add("中");
        list.add("国");
        list.add("！");
//        list.forEach { ele->
//            list.remove(ele)
//        }
//       for (ele in list) {
//           list.remove(ele)
//       }
        for (i in list) {
            println("执行元素删除下标index=$i")
            list.remove(i)
        }
        //       val iterator = list.iterator();
//       while (iterator.hasNext()&&null!=iterator.next()) {
//           iterator.remove()
//       }
    }


    class JoinDemo(//上一个线程
        var previousThread: Thread, var i: Int
    ) : Thread() {

        override fun run() {
            println("num11111")
            Thread.sleep(1000)
            println("num22222")
        }

        companion object {
            @JvmStatic
            fun main(args: Array<String>) {
            }
        }

    }

    @Test
    fun exeThread() {
        var previousThread = Thread.currentThread()
        println("执行开始...")
            val joinDemo = JoinDemo(previousThread,0)
            joinDemo.start()
//            joinDemo.join()
        println("执行结束...")
    }
}
